//
//  DatabaseService.m
//  deerkids
//
//  Created by 王昭的Mac Air on 2017/9/1.
//  Copyright © 2017年 wangzhao. All rights reserved.
//

#import "DatabaseService.h"

@implementation DatabaseService

//#define DB_PATH [NSString stringWithFormat:@"%@/Documents/file/db.sqlite",NSHomeDirectory()]

+ (void)createHotwordTable
{
    NSString *path = [DOCUMENT_PATH stringByAppendingPathComponent:@"file"];
    NSFileManager *manager = [NSFileManager defaultManager];
    if (![manager fileExistsAtPath:path]) {     //创建路径
        [manager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    }
    
    FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:DB_PATH];
    [queue inDatabase:^(FMDatabase * _Nonnull db) {
        NSString *sql = [NSString stringWithFormat:@"create table if not exists hotword(uid integer, word text, lastAccessTime text, primary key(uid, word))"];
        BOOL ret = [db executeUpdate:sql];
        DLog(@"%@",ret?@"创建成功":@"创建失败");
    }];
}


@end
